<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"                  
                xmlns:h="http://java.sun.com/jsf/html"                  
                xmlns:f="http://java.sun.com/jsf/core"
                template="/resources/modelo_facelets.xhtml">    

    <ui:define name="content">

        <p:panel id="atributospadrao" header="Atributos Fixos">
            
            <h:panelGrid columns="1" cellspacing="20px" width="100%" style="text-align: left">
                
                <h:outputText value="#{msgs.atributosFixosAtendente}" />
                <h:outputText value="#{msgs.atributosFixosChamado}" />
                <h:outputText value="#{msgs.atributosFixosEquipe}" />
                <h:outputText value="#{msgs.atributosFixosFluxo}" />
                <h:outputText value="#{msgs.atributosFixosServico}" />
                <h:outputText value="#{msgs.atributosFixosSolicitante}" />
                
            </h:panelGrid>
            
        </p:panel>
        
        
        <p:panel id="painelprincipal" header="#{crud.msgPainelPrincipal}">         

            <p:messages/>           

            <h:form id="formAdicionar">

                <h:panelGrid columns="2" cellspacing="20px" width="100%">

                    <h:outputLabel value="Nome do Atributo:" />  

                    <p:inputText id="nomeAtributo" 
                                 value="#{crud.nomeAtributo}" 
                                 required="true" 
                                 requiredMessage="O nome do atributo é obrigatório!"
                                 label="Nome do Atributo">  
                        <f:validateLength minimum="2" />  

                    </p:inputText>  

                    <h:outputLabel value="Tipo do Atributo: " />  

                    <p:selectOneMenu id="tipoAtributo" value="#{crud.tipoAtributo}">
                        <f:selectItems value="#{crud.listaTiposAtributos}" var="item" itemValue="#{item.toString}" itemLabel="#{item.toString}"/>
                    </p:selectOneMenu>

                </h:panelGrid>

                <p:commandButton value="Adicionar" 
                                 actionListener="#{crud.adicionarAtributo()}" 
                                 update=":painelprincipal :paineltabela"/>
            </h:form>

        </p:panel>

        <p:panel id="paineltabela" header="Atributos Cadastrados" >
            
            <h:form id="formTabela">        

                <p:dataTable id="tabela"                                           
                             value="#{crud.tabela}"
                             var="itemCrud"                                       
                             rows="10"  
                             pageLinks="5"
                             rowsPerPageTemplate="5,10,15"
                             selectionMode="single"
                             selection="#{crud.atributoSelecionado}"
                             paginator="true"       
                             emptyMessage="Nenhum registro encontrado."
                             paginatorPosition="bottom"                             
                             paginatorTemplate="{RowsPerPageDropdown} {CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"                             
                             >

                    <p:column headerText="Nome do Atributo" sortBy="#{itemCrud.nomeAtributo}" filterBy="#{itemCrud.nomeAtributo}">
                        <h:outputText value="#{itemCrud.nomeAtributo}"/>                              
                    </p:column>                      

                    <p:column headerText="Tipo do Atributo" sortBy="#{itemCrud.tipo}" filterBy="#{itemCrud.tipo}">
                        <h:outputText value="#{itemCrud.tipo}"/>                              
                    </p:column>     

                    <f:facet name="footer">
                        <p:commandButton value="Excluir" action="#{crud.excluirAtributo()}" update=":painelprincipal :paineltabela" />
                    </f:facet>

                </p:dataTable>

            </h:form>

        </p:panel> 

    </ui:define>

</ui:composition>